/*------------------------------------------------------------------------
# JA Showcase 1.0.0 - May, 2007
# ------------------------------------------------------------------------
# Copyright (C) 2004-2007 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
-------------------------------------------------------------------------*/

function jacompmenuInit() {
	var menu = document.getElementById("ja-component-menu");
	var lis = menu.getElementsByTagName("LI");
	for (var i = 0; i < lis.length; ++i) {
		if (lis[i].className == "main" && lis[i].lastChild.nodeName == "UL" && lis[i].firstChild.className != "active") {
			sublis = lis[i].getElementsByTagName("LI");
			active = false;
			for (var j = 0; j < sublis.length; ++j) {
				if (sublis[j].firstChild.className == "active") { active = true; break; }
			}
			if (active) lis[i].lastChild.style.display = "inline";
		} else if (lis[i].className == "main" && lis[i].firstChild.className == "active" && lis[i].lastChild.nodeName == "UL") {
			lis[i].lastChild.style.display = "inline";
		}

		if (lis[i].lastChild.nodeName == "UL") {
			lis[i].firstChild.firstChild.onclick = function() {
				if (this.parentNode.parentNode.lastChild.className != "show")
					this.parentNode.parentNode.lastChild.className = "show";
				else
					this.parentNode.parentNode.lastChild.className = "";
			}
		}
	}
}

function jacompmenuAddEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

jacompmenuAddEvent(window, "load", jacompmenuInit);